import { ApiProperty } from '@nestjs/swagger';

export class ApiProjectExportReqDto {
  @ApiProperty({ description: '项目ID', required: true })
  projectId: string;

  @ApiProperty({ description: '导出文件名', required: false })
  fileName?: string;

  @ApiProperty({ description: '是否上传到Minio', required: false, default: false })
  uploadToMinio?: boolean;

  @ApiProperty({ description: 'Minio文件名', required: false })
  minioFileName?: string;

  @ApiProperty({ description: '是否保留本地副本', required: false, default: true })
  keepLocalCopy?: boolean;
}

export class ApiProjectImportReqDto {
  @ApiProperty({ description: '上传的ZIP文件', required: true })
  file: any;

  @ApiProperty({ description: '是否覆盖同名项目', required: false })
  overwrite?: boolean;

  @ApiProperty({ description: '新项目名前缀', required: false })
  namePrefix?: string;
}

export class ApiProjectExportResDto {
  @ApiProperty({ description: '导出状态', required: true })
  success: boolean;

  @ApiProperty({ description: '下载链接', required: false })
  downloadUrl?: string;

  @ApiProperty({ description: 'Minio URL', required: false })
  minioUrl?: string;

  @ApiProperty({ description: '本地文件路径', required: false })
  localPath?: string;

  @ApiProperty({ description: '导出文件名', required: false })
  fileName?: string;

  @ApiProperty({ description: '文件大小', required: false })
  fileSize?: number;

  @ApiProperty({ description: '错误信息', required: false })
  error?: string;
}

export class ApiProjectImportResDto {
  @ApiProperty({ description: '导入状态', required: true })
  success: boolean;

  @ApiProperty({ description: '新项目ID', required: false })
  projectId?: string;

  @ApiProperty({ description: '导入的项目名称', required: false })
  projectName?: string;

  @ApiProperty({ description: '导入统计', required: false })
  stats?: {
    projects: number;
    documents: number;
    types: number;
  };

  @ApiProperty({ description: '错误信息', required: false })
  error?: string;
}

// Minio 专用 DTO
export class ApiMinioUploadReqDto {
  @ApiProperty({ description: '项目ID', required: true })
  projectId: string;

  @ApiProperty({ description: 'Minio文件名', required: false })
  fileName?: string;
}

export class ApiMinioUploadResDto {
  @ApiProperty({ description: '上传状态', required: true })
  success: boolean;

  @ApiProperty({ description: 'Minio URL', required: false })
  minioUrl?: string;

  @ApiProperty({ description: '文件名', required: false })
  fileName?: string;

  @ApiProperty({ description: '文件大小', required: false })
  fileSize?: number;

  @ApiProperty({ description: '错误信息', required: false })
  error?: string;
}

export class ApiProjectResourcesUploadReqDto {
  @ApiProperty({ description: '项目ID', required: true })
  projectId: string;

  @ApiProperty({
    description: '资源列表',
    required: true,
    type: 'array',
    items: {
      type: 'object',
      properties: {
        originalUrl: { type: 'string', description: '原始URL' },
        fileName: { type: 'string', description: '文件名' },
        buffer: { type: 'string', description: '文件base64编码' }
      }
    }
  })
  resources: Array<{
    originalUrl: string;
    fileName: string;
    buffer: string; // base64编码的文件内容
  }>;
}

export class ApiProjectResourcesUploadResDto {
  @ApiProperty({ description: '上传状态', required: true })
  success: boolean;

  @ApiProperty({ description: '成功上传的资源', required: false })
  uploaded?: Array<{
    originalUrl: string;
    url: string;
    key: string;
  }>;

  @ApiProperty({ description: '失败的资源', required: false })
  failed?: Array<{
    originalUrl: string;
    error: string;
  }>;

  @ApiProperty({ description: '错误信息', required: false })
  error?: string;
}

export class ApiProjectMinioInfoReqDto {
  @ApiProperty({ description: '项目ID', required: true })
  projectId: string;
}

export class ApiProjectMinioInfoResDto {
  @ApiProperty({ description: '查询状态', required: true })
  success: boolean;

  @ApiProperty({ description: '对象列表', required: false })
  objects?: any[];

  @ApiProperty({ description: '总大小', required: false })
  totalSize?: number;

  @ApiProperty({ description: '对象数量', required: false })
  objectCount?: number;

  @ApiProperty({ description: '错误信息', required: false })
  error?: string;
}